<template>
	<view class="hot-list">
		<view class="header">
			<view class="title row mb20">
				<image src="../../static/images/icon_paixu.png" class="icon mr20"></image>
				<text class="xs white">实时更新热销火爆商品</text>
			</view>
			<swipers :pid="15" height="284rpx" radius="10rpx"></swipers>
		</view>
		<view class="main">
			<view v-if="hasHot">
				<goods-list type="hot" :list="goodsList"></goods-list>
				<loading-footer :status="status">

				</loading-footer>
			</view>
			<view v-else class="column-center" style="padding-top: 400rpx">
				<image class="img-null"  :src="`${imgPrefix}/images/xcxweb/goods_null.png`"></image>
				<text class="lighter">暂无商品~</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		loadingType
	} from '@/utils/type';
	import {
		getHotGoods
	} from '@/api/store';

	import {loadingFun} from '@/utils/tools'
	import { baseURL } from "@/config/app"
		
	export default {
		data() {
			return {
				goodsList: [],
				page: 1,
				status: loadingType.LOADING,
				hasHot: true,
				imgPrefix: baseURL
			};
		},

		components: {},
		props: {},


		onLoad(options) {
			this.getHotGoodsFun();
		},

		onReachBottom() {
			this.getHotGoodsFun();
		},


		methods: {
			async getHotGoodsFun() {
				let {
					page,
					status,
					goodsList
				} = this;
				const data = await loadingFun(getHotGoods,page, goodsList,status)
				if (!data) return
				this.page = data.page
				this.goodsList = data.dataList
				this.status = data.status
			}

		}
	};
</script>
<style lang="scss">
	.hot-list {
		background: url(../../static/images/hot_list_bg.png) no-repeat;
		background-size: 100% 330rpx;
		padding: 62rpx 30rpx 0;
		min-height: 100vh;
		box-sizing: border-box;
		.main {
			padding: 0 0 20rpx;
		}
		.data-null {
			padding-top: 150rpx;
		}
		
	}

</style>
